﻿using Chat_IService;
using Chat_Model;
using Chat_Model.ViewModel;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Chat_Service
{
    public class LarUsersFriendsService : BaseService<LarUsersFriends>, ILarUsersFriendsService
    {
        /// <summary>
        /// 获取好友列表
        /// </summary>
        /// <param name="uid"></param>
        /// <returns></returns>
        public async Task<List<LarUsersFriendsDto>> GetContactsList(int uid)
        {
            var list = await Context.Queryable<LarUsersFriends>()
                  .LeftJoin<LarUsers>((f, u) => f.FriendId == u.Id)
                  .Where(f => f.UserId == uid)
                  .Select((f, u) => new LarUsersFriendsDto
                  {
                      Id = u.Id,
                      Nickname = u.Nickname,
                      Avatar = u.Avatar,
                      Motto = u.Motto,
                      Gender = u.Gender,
                      Friend_remark = f.Remark,
                      Is_Online = false
                  }).ToListAsync();
            return list;
        }
        ///// <summary>
        ///// 获取可邀请加入群组的联系人列
        ///// </summary>
        ///// <returns></returns>
        //public async Task<> GetInviteFriends() { 
        
        //}
    }
}